title | date | tags | draft | summary | ||
---|---|---|---|---|---|---|
Integer Division Result in Decimal in SQL server |
2021-09-23 |
|
false |
Get the Decimal result from deviding Integers in SQL Server |
Get the result in Decimal value by dividing Integer values in SQL Server.
Ex:
SELECT 5/2
--Actual 2
--Expected 2.5
Convert to decimal
SELECT CONVERT(decimal(4,2), 5) /2
--2.500000
Multiplying by 1.0 Converts value into numeric
SELECT 5*1.0/2
--2.500000
Shorthand method *1.
SELECT 5*1./2
--2.500000